﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using ComLib;

namespace System
{
    public static class DataTableToHierarchicalDataExtensions
    {
        /// <summary>
        /// To the hierarchical data.
        /// </summary>
        /// <param name="dataTable">The data table.</param>
        /// <param name="dataIdField">The data id field.</param>
        /// <param name="dataParentIdField">The data parent id field.</param>
        /// <returns></returns>
        public static CustomHierarchicalDataSource ToHierarchicalData(this DataTable dataTable, string dataIdField,
                                                                      string dataParentIdField)
        {
            if (dataTable == null) return null;
            return new CustomHierarchicalDataSource(dataTable, dataIdField, dataParentIdField);
        }
    }
}
